import {Button, Form, Input} from "antd";
import _ from "lodash";
import {useNavigate} from "react-router-dom";
import "./login.less";

const user = {
    username: "ZCSYM",
    password: "GDAAS",
};

const Login = () => {
    const nav = useNavigate();
    const [form] = Form.useForm();
    const onFinish = (values: any) => {
        if (_.isEqual(values, user)) {
            nav("/home");
            localStorage.setItem("admin", "aaa");
        }
    };

    return (
        <div className="login-page">
            <div className="form">
                <div className="title">广东丝苗米品质数据库</div>
                <Form form={form} onFinish={onFinish}>
                    <Form.Item label="账号" name="username" required>
                        <Input />
                    </Form.Item>
                    <Form.Item label="密码" name="password" required>
                        <Input.Password />
                    </Form.Item>
                    <Form.Item>
                        <Button type="primary" className="login" htmlType="submit">
                            确认登录
                        </Button>
                    </Form.Item>
                </Form>
            </div>
        </div>
    );
};

export default Login;
